package com.squid.base.config.filter;

import com.squid.base.config.filter.HttpRequestLogFilter;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * Description
 *
 * @author jinhang
 * @since 2024-3-28
 **/
@Configuration
@Import({HttpRequestLogFilter.class})
@Slf4j
public class FilterConfig {
    @Resource
    HttpRequestLogFilter httpRequestLogFilter;

    @Bean
    public FilterRegistrationBean<HttpRequestLogFilter> httpRequestLogFilterRegistration() {
        log.info("注册httpRequestLog的Filter");
        FilterRegistrationBean<HttpRequestLogFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(httpRequestLogFilter);
        registration.addUrlPatterns("/*");
        registration.setName("httpRequestLogFilter");
        registration.setOrder(10);
        return registration;
    }
}
